public class JiYueFractions {
    public static void main(String[] args) {
        int count = 0;
        for (int i = 1; i <= 2020; i++) {
            for (int j = 1; j <= 2020; j++) {
                if (isJiYue(i, j)) {
                    count ++;
                }
            }
        }
        System.out.println(count);
    }

    public static boolean isJiYue(int num1, int num2) {
        if (num1 == 0 || num2 == 0) {
            if (num1 == 1) {
                return true;
            }
            return false;
        }
        if (num1 < num2) {
            int tmp = num1;
            num1 = num2;
            num2 = tmp;
        }
        int a = num1;
        num1 = num2;
        num2 = a % num2;
        return isJiYue(num1, num2);
    }
}
